<template>
    <div class="tain">
        <van-cell-group>
           <van-list
            v-model="loading"
            :finished="finished"
            finished-text="没有更多了"
            @load="onLoad"
            >
            <van-cell v-for="item in list" :key="item.ch_id" :title="item.title" />
            </van-list>
        </van-cell-group>    
    </div>
</template>
<script>
import { getSearchitem } from '@/api/search.js'
export default {
  data:function(){
    return {
      page:1,
      perPage:20,
      list: [],
      loading: false,
      finished: false
    }
  },
  props:(['value']),
  // 去查询接口数据
  methods:{
    //  getlis(){
    //     
    //     console.log(os)
    // }
    async onLoad() {
      // 异步更新数据
      const parm = {
        page: this.page, // 页码
        per_page: this.perPage, // 每页大小
        q: this.value // 搜索关键字
      }
      console.log(this.value)
      // setTimeout 仅做示例，真实场景中一般为 ajax 请求         
      const os = await getSearchitem(parm)  
      const ins = os.data.data.results         
      if (ins.length > 0){
        this.list.push(...ins)
        this.loading = false
      } else {
        this.loading = true
        this.finished = true
      }
      console.log(os)
      this.page++                  
    }
  }   
}
</script>
<style lang="less">

</style>
